<template>
  <div>
    <cube-button @click="handleLogin">登录</cube-button>
  </div>
</template>

<script>
import { apiShopAdmin } from '@/properties/api.js'
export default {
  name: 'Login',
  data () {
    return {

    }
  },
  methods: {
    login (cbOk, cbErr) {
      this.$axios.post(
        apiShopAdmin.login,
        null,
        cbOk,
        cbErr
      )
    },

    handleLogin () {
      let $this = this
      $this.login(
        function (res) {
          $this.toast = $this.$createToast({
            txt: '登录成功',
            type: 'correct'
          })
          $this.toast.show()
          $this.$router.push('/shopregister')
        }, function (err) {
          $this.toast = $this.$createToast({
            txt: err.msg,
            type: 'error'
          })
          $this.toast.show()
        }
      )
    }
  }
}
</script>

<style scoped>

</style>
